#coding=utf-8

import urllib
import httplib
import data.config
import time
conn=httplib.HTTPConnection(data.config.Getmachineip())

print data.config.Getmachineip()
def getvolume():
    time.sleep(1)
    conn.request('GET', '/api/request-dev')
    getinformation=conn.getresponse()
    readinformation=getinformation.read()
    getdeviceinfo=eval(readinformation)
    currentvolume=getdeviceinfo['volume']
    return currentvolume
    conn.close()  
   
def songname():
    time.sleep(15)
    conn.request('GET', '/api/request-dev')
    getinformation=conn.getresponse()
    readinformation=getinformation.read()
    getsongname=eval(readinformation)
    currentname=getsongname['name']
    #print currentname
    return currentname
    conn.close()
   
def got_current_music_time():
    conn.request('GET', '/api/request-dev')
    getinformation=conn.getresponse()
    readinformation=getinformation.read()
    get_information=eval(readinformation)
    current_time=get_information['current_time']
    return current_time
    conn.close()

if __name__ =="__main__":
    getvolume()
    songname()
    got_current_music_time()
    time.sleep(5)


